If --target is specified, pass that to build commands
authorAlex Crichton <alex@alexcrichton.com>
Sun, 17 Aug 2014 05:10:36 +0000 (22:10 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 17 Aug 2014 05:17:55 +0000 (22:17 -0700)
0c834d7b accidentally broke this by favoring rustc's target triple over the
actual target triple.

src/cargo/ops/cargo_rustc/context.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_cross_compile.rs

index 96186d5351cf81a169c3b92fb148792c4e480882..45bc56b37a76a3d6cae9b52b0c2e4911566cad62 100644 (file)
@@ -48,7 +48,9 @@ impl<'a, 'b> Context<'a, 'b> {
             let (dylib, _) = try!(Context::filename_parts(None));
             dylib
         };
-        let (rustc_version, target_triple) = try!(Context::rustc_version());
+        let (rustc_version, rustc_host) = try!(Context::rustc_version());
+        let target_triple = config.target().map(|s| s.to_string());
+        let target_triple = target_triple.unwrap_or(rustc_host);
         Ok(Context {
             rustc_version: rustc_version,
             target_triple: target_triple,
index 18bd5f634d79e96167b5218ecee46a7109540cd0..4a857aea0f2cf717b1be56f8a71fe4a6bb9888f7 100644 (file)
@@ -919,7 +919,7 @@ test!(dep_with_changed_submodule {
 
     let mut file = File::create(&git_project.root().join(".gitmodules"));
     file.write_str(format!("[submodule \"src\"]\n\tpath = src\n\turl={}",
-                           git_project3.url()).as_slice());
+                           git_project3.url()).as_slice()).assert();
 
     git_project.process("git").args(["submodule", "sync"]).exec_with_output().assert();
     git_project.process("git").args(["fetch"]).cwd(git_project.root().join("src"))
index 09a8361e84760112b55e5ce89a06b8ef0f1c7228..a85f5e75a06fa2d06df352604e87a439c8afa329 100644 (file)
@@ -32,9 +32,31 @@ fn alternate() -> &'static str {
 test!(simple_cross {
     if disabled() { return }
 
+    let mut build = project("builder");
+    build = build
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            version = "0.5.0"
+            authors = ["wycats@example.com"]
+        "#)
+        .file("src/main.rs", format!(r#"
+            fn main() {{
+                assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
+            }}
+        "#, alternate()).as_slice());
+    assert_that(build.cargo_process("cargo-build"),
+                execs().with_status(0));
+
     let p = project("foo")
-        .file("Cargo.toml", basic_bin_manifest("foo").as_slice())
-        .file("src/foo.rs", r#"
+        .file("Cargo.toml", format!(r#"
+            [package]
+            name = "foo"
+            version = "0.0.0"
+            authors = []
+            build = '{}'
+        "#, build.bin("foo").display()))
+        .file("src/main.rs", r#"
             use std::os;
             fn main() {
                 assert_eq!(os::consts::ARCH, "x86");